package com.xcdh.orm.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

@Data
@TableName("orm_data_source")
public class OrmDataSource extends BaseEntity{

    @TableId(type = IdType.AUTO)
    private Integer id;

    @TableField(value = "url")
    private String url;

    @TableField(value = "user_name")
    private String userName;

    @TableField(value = "password")
    private String password;

    @TableField(value = "driver")
    private String driver;

    @TableField(value = "ds_Name")
    private String dsName ;

    @TableField(exist = false)
    public String dbName ;
    public String getDbName(){
        if(driver == null){
            return null ;
        }
        if(driver.contains("mysql")){
            return "mysql" ;
        } else if (driver.contains("oracle")) {
            return "oracle" ;
        }
        return null ;
    }

}
